forcecell 2.2.0
Loading...
Searching...
No Matches
forcecell


Force Cell Click

Force Cell Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : May 2025.
  • Type : ADC/I2C type

Software Support

Example Description

This example demonstrates the use of the Force Cell Click board by reading the applied force in newtons (N) from a load cell sensor. The application initializes the driver, calibrates the offset, and continuously measures and logs the force value to the USB UART terminal.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ForceCell

Example Key Functions

Application Init

Initializes the logger and the Click driver, performs offset calibration to null the load cell.

void application_init ( void )
{
log_cfg_t log_cfg;
forcecell_cfg_t forcecell_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
forcecell_cfg_setup( &forcecell_cfg );
FORCECELL_MAP_MIKROBUS( forcecell_cfg, MIKROBUS_1 );
err_t init_flag = forcecell_init( &forcecell, &forcecell_cfg );
if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( FORCECELL_ERROR == forcecell_calib_offset ( &forcecell ) )
{
log_error( &logger, " Offset calibration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ FORCECELL_ERROR
Definition forcecell.h:185
#define FORCECELL_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition forcecell.h:123
void application_init(void)
Definition main.c:29

Application Task

Continuously reads and displays the current force value in newtons every 100ms.

void application_task ( void )
{
float force = 0;
if ( FORCECELL_OK == forcecell_read_force ( &forcecell, &force ) )
{
log_printf( &logger, " Force : %.3f N\r\n\n", force );
Delay_ms ( 100 );
}
}
@ FORCECELL_OK
Definition forcecell.h:184
void application_task(void)
Definition main.c:66

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.